package andreTegningerGUI;

import context.*;

import java.awt.Color;
import java.awt.Image;
import java.awt.Graphics;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;

import javax.swing.JPanel;


// ***************************************************************************
// *** CLASS: JImagePanel
// ***************************************************************************
public class JImagePanel extends JPanel implements Context.Constants
{ //private static final boolean DEBUG=true; // Overriding Context.Constants.DEBUG
  static final long serialVersionUID=0; // TODO ?
  private Image image;


  // *************************************************************************
  // *** CONSTRUCTOR: JImagePanel
  // *************************************************************************
  /**
  * Constructs a JImagePanel object.
  * @param drawing .
  */
  public JImagePanel(Image image)
  { this.image=image;
    this.addComponentListener(componentListener);
    this.setBackground(Color.white);
  }

  // *************************************************************************
  // *** METHOD: paint
  // *************************************************************************
  /**
  * This method is called to repaint this JComponent.
  * @param g the graphics context.
  **/
  public void paint(Graphics g)
  { g.drawImage(image,0,0,null); }

  // ***************************************************************************
  // *** ComponentListener: Methods
  // ***************************************************************************
  private ComponentListener componentListener=new ComponentListener()
  {
    //** Invoked when the component's size changes. **/
    public void componentResized(ComponentEvent e) { }

    //** Invoked when the component's position changes. **/
    public void componentMoved(ComponentEvent e) {}

    //** Invoked when the component has been made visible. **/
    public void componentShown(ComponentEvent e) {}

    //** Invoked when the component has been made invisible. **/
    public void componentHidden(ComponentEvent e) {}

  };

}